let name = 'tom'

export function fn() {
  console.log(name)
}

/* 
编译后的伪代码
() => {
  let name = 'tom'

  function fn() {
    console.log(name)
  }

  return {
    fn: fn
  }
}
*/


export const a1 = 'abc'
export const a2 = 'abc2'
export default function fn () {}
export default function fn2 () {}
const a3 = 2
const a4 = 5
export {
  a3,
  a4
}

/* 
整个模块永远是一个对象: {}, 任何暴露语法都是向这个对象添加属性/方法
{
  a1: 'abc',
  a2: 'abc2',
  default: function () {},
  a3,
  a4,
}

import {a1, a2, a3, a4} from './test'
import xxx from './test'
import {default as xxx} from './test
import * as test from './test'
*/

const arr = [1, 3, 5]
const arr2 = arr.slice()

Array.prototype.slice = function () {
  const result = []

  for (var index = 0; index < this.length; index++) {
    result[index] = this[index]
  }

  return result
}

/* 我们可以让一个函数成为任意对象的方法进行调用 */
const obj = { // 数值下标属性
  0: 'a',
  1: 'b',
  length: 2
}
// Array.prototype.slice
// [].slice.call(obj) ==> ['a', 'b']  obj.slice()

// function fn() {
//   // arguments
//   [].slice.call(arguments).forEach(value => {
    
//   });
// }

fn('a', 'b')